package com.applications.codemash.groupers;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.applications.codemash.core.GrouperBase;
import com.applications.codemash.core.Session;

public class SessionListGroupBySpeaker extends GrouperBase
{
	@Override
	public Map<String, List<Session>> Group(List<Session> sessionList)
	{
		Map<String, List<Session>> returnMap = new HashMap<String, List<Session>>();
		for (int i=0; i<sessionList.size(); i++)
		{
			String speaker = sessionList.get(i).getSpeakerName();
			if (!returnMap.containsKey(speaker))
			{
				returnMap.put(speaker, new ArrayList<Session>());
			}
			
			returnMap.get(speaker).add(sessionList.get(i));
		}
		
		return Sort(returnMap);
	}
}
